
/* class Father{
    // 属性
    name:string = "";
    age:number;
    sex:string;
    // 方法
    constructor(name:string,age:number,sex:string){
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    // 原型对象 添加方法
    speak():void{
        console.log(`我是${this.name},我今年${this.age}岁了，我是个${this.sex}滴`);
    }
    //实例对象添加方法
    run = ()=>{

    }
}

class Son extends Father{

    height:number;

    constructor(name:string,age:number,sex:string,height:number){
        super(name,age,sex);    // 父类的构造函数
        this.height = height;
    }


    //重写父类方法
    speak():void{
        console.log("我是儿子");
    }

}

 */


//实例化对象
// let f = new Father("张三",18,"男");

// console.log(f);

// f.speak();


//实例化对象
/* let s  = new Son("李四",10,"男",180);
console.log(s);

console.log(s.speak());

export {} */



//类的成员修饰符
//继承
class Father {
    public name: string;
    protected age: number;
    private salary: number;
  
    constructor(name: string, age: number, salary: number){
      this.name = name;
      this.age = age;
      this.salary = salary;
    }
  
    info(){
      console.log(this.name);
      console.log(this.age);
      console.log(this.salary);
    }
  }
  
  class Son extends Father{
    constructor(name: string, age: number, salary: number){
      super(name, age, salary);
    }
    
    checkSalary(){
        //   public  √
      console.log(this.name);
        // protected  √
      console.log(this.age);
        // private  X
    //   console.log(this.salary);
    }
  }
  
  let xue = new Son('xue', 26, 16000);
  
//   public  √
//   console.log(xue.name);
  // protected  ×
//   console.log(xue.age);
//  private ×
// console.log(xue.salary);


xue.info();